package com.qingfeng.testandroid12sdkdemo.coroutine

import kotlinx.coroutines.CoroutineName
import kotlin.coroutines.Continuation
import kotlin.coroutines.ContinuationInterceptor
import kotlin.coroutines.CoroutineContext

class LogInterceptor : ContinuationInterceptor {
    override val key = ContinuationInterceptor

    override fun <T> interceptContinuation(continuation: Continuation<T>) = LogContinuation(continuation)

}

class LogContinuation<T>(private val continuation: Continuation<T>) : Continuation<T> by continuation {
    override fun resumeWith(result: Result<T>) {
        print("before resumeWith: $result")
        continuation.resumeWith(result)
        print("after resumeWith: $result")
    }
}


interface Generator<T> {
    operator fun iterator(): Iterator<T>
}




//fun <T> generator(block: suspend GeneratorScope<T>.(T) -> )